package game;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;


public abstract class Sprite {
	
	float X;
	float Y;
	float TX;
	float TY;
	float angle = 1;
	boolean alive;
	
	BufferedImage bSprite = null;
	
	public Sprite(BufferedImage bg, float x, float y, float tx, float ty){		
		if(bg != null){
			bSprite = bg;						
		}
		
		X = x;
		Y = y;
		TX = tx;
		TY = ty;
		
		alive = true;		
		
	}
	
	public abstract void Simulase(long diffTempo);
	int teste =0;
	public void Desenha(Graphics2D dbg){		
		if(alive){
			if(bSprite != null){
				if(angle !=1){
//					AffineTransform teste = dbg.getTransform();
//					
//					dbg.rotate(Math.toRadians(angle), bSprite.getWidth()/2, bSprite.getHeight()/2);
//					dbg.drawImage(bSprite, (int)X, (int)Y, (int)TX, (int)TY, null);
//					dbg.setTransform(teste);
					dbg.drawImage(bSprite, (int)X, (int)Y, (int)TX, (int)TY, null);	
//										
				}else{
					dbg.drawImage(bSprite, (int)X, (int)Y, (int)TX, (int)TY, null);	
				}
				
				
			}
		}
	}
	
	public boolean Colision(Sprite sprite){
		
		float ob1x1 = X;
		float ob1x2 = X + TX;
		float ob2x1 = sprite.X;
		float ob2x2 = sprite.X + sprite.TX;
		
		float ob1y1 = Y;
		float ob1y2 = Y + TY;
		float ob2y1 = sprite.Y;
		float ob2y2 = sprite.Y + sprite.TY;
		
		if((ob1x1 < ob2x2) && (ob1x2 > ob2x1) && (ob1y1 < ob2y2) && (ob1y2 > ob2y1)){
			return true;
		}else{
			return false;
		}			
	}
	
	public void Rotate(float angulo){
		
	}
}
